import Vue from 'vue'
import App from './App'
import axios from 'axios'
import request from './network/request'

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  render: h => h(App)
})

axios.defaults.baseURL = 'http://123.207.32.32:8000'
// axios.defaults.headers.post['Content-Type']
axios.defaults.timeout = 5000

axios({
  url: '/home/multidata'
}).then(res => {
  console.log(res)
})

axios({
  url: '/home/data',
  params: {
    type: 'pop',
    page: 1
  }
}).then(res => {
  console.log(res)
})

axios.get('/home/multidata', {
  type: 'pop',
  page: 1
}).then(res => {
  console.log(res)
})

// 并发发送请求
axios.all([axios({
  url: '/home/multidata'
}), axios({
  url: '/home/data',
  params: {
    type: 'pop',
    page: 1
  }
})])
  .then(res => {
    console.log(res)
  })

// 创建一个实例
const instance1 = axios.create({
  baseURL: 'http://123.207.32.32:8000',
  timeout: 5000
})

instance1({
  url: '/home/data',
  params: {
    type: 'pop',
    page: 1
  }
}).then(res => {
  console.log(res)
})

request({
  url: '/home/data',
  params: {
    type: 'pop',
    page: 1
  }
}).then(res => {
  console.log(res, '封装')
})